﻿// -----------------------------------------------------------------------
// <copyright file="ErrorResult.cs" company="EPAM Systems">
////Copyright (c) EPAM Systems, 2012. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
namespace MBOP.Website.CustomResults
{
	#region Usings

	using System.Web.Mvc;

	#endregion

	/// <summary>
	/// Encapsulate the error result of an action method and is used to perform a framework-level operation on behalf of the action method.
	/// </summary>
	public class ErrorResult : ViewResult
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="ErrorResult"/> class.
		/// </summary>
		/// <param name="viewName">The rendering view.</param>
		/// <param name="model">The view model.</param>
		public ErrorResult(string viewName, object model)
		{
			this.ViewName = viewName;
			this.ViewData.Model = model;
		}

		/// <summary>
		/// Enables processing of the result of an action method.
		/// </summary>
		/// <param name="context">Controller context, which processing the current request.</param>
		public override void ExecuteResult(ControllerContext context)
		{
			context.HttpContext.Response.StatusCode = 500;

			base.ExecuteResult(context);
		}
	}
}